//
//  MyPageController.m
//  WashForU
//
//  Created by 王俊 on 15/11/25.
//  Copyright © 2015年 王俊. All rights reserved.
//

#import "MyPageController.h"

@interface MyPageController ()
@property(nonatomic,strong)UIView      *exUpView;
@end

@implementation MyPageController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self customViewSetUp];
    [self customConstrainsAdd];
    [self targetAdd];
}
/*****************添加视图组件********************/
- (void)customViewSetUp
{
    self.view.backgroundColor   = [UIColor whiteColor];
    self.upView.hidden  = true;
    self.exUpView = [[UIView alloc]init];
    self.exUpView.backgroundColor = [UIColor CustomLightBlue];
    self.backButton.hidden      = true;
    Contact *personInfo         = [Contact initWithInfo:@"王俊"
                                              phoneNumb:@"13806502567"
                                                   code:@"998FFF"
                                         numbOfCodeLeft:@"8"];
    _tpView                     = [TopView initWithContact:personInfo];
    
    _myOder       = [[CustomButton alloc]initWithImageAndLabel:@"我的订单" highLightedImageName:@"我的订单H" labelText:@"我的订单"];
    _laundryCoin  = [[CustomButton alloc]initWithImageAndLabel:@"洗衣币" highLightedImageName:@"洗衣币H" labelText:@"我的帐户"];
    _myAddress    = [[CustomButton alloc]initWithImageAndLabel:@"我的地址" highLightedImageName:@"我的地址H" labelText:@"我的地址"];
    _shareCode    = [[CustomButton alloc]initWithImageAndLabel:@"分享推荐码" highLightedImageName:@"分享推荐码H" labelText:@"分享推荐码"];
    _validateCode = [[CustomButton alloc]initWithImageAndLabel:@"验证推荐码" highLightedImageName:@"验证推荐码H" labelText:@"验证推荐码"];
    [self.view addSubview:self.exUpView];
    [self.view addSubview:_myOder];
    [self.view addSubview:_laundryCoin];
    [self.view addSubview:_myAddress];
    [self.view addSubview:_shareCode];
    [self.view addSubview:_validateCode];
    [self.view addSubview:_tpView];

    
}
/*******************添加约束**********************/
- (void)customConstrainsAdd
{
    [self.exUpView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(self.view).multipliedBy(42.0/114.0);
        make.top.leading.trailing.equalTo(self.view);
    }];
    [_myOder mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo((SCREENWIDTH - 40)/3);
        make.height.mas_equalTo((SCREENWIDTH - 40)*26/60);
        make.leading.equalTo(self.view).offset(10);
        make.top.equalTo(self.exUpView.mas_bottom).offset(15);
    }];
    [_laundryCoin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.size.top.equalTo(_myOder);
    }];
    [_myAddress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.top.equalTo(_myOder);
        make.trailing.equalTo(self.view).offset(-10);
    }];
    [_shareCode mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.leading.equalTo(_myOder);
        make.top.equalTo(_myOder.mas_bottom).offset(15);
    }];
    [_validateCode mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.leading.equalTo(_laundryCoin);
        make.top.equalTo(_laundryCoin.mas_bottom).offset(15);
    }];

    [_tpView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.exUpView);
    }];
    
}

/*******************添加事件**********************/
- (void)targetAdd
{
    [self.laundryCoin.buttonImage addTarget:self action:@selector(laundryCoinClicked) forControlEvents:UIControlEventTouchUpInside];
    //[self.backButton addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
}

- (void)laundryCoinClicked
{
    //navigation到新的Page
    MyAccountPageController *vc =[[MyAccountPageController alloc]init];
    [self.navigationController pushViewController:vc animated:true];
    
}

@end
